<#include "layout.html" />
<@head title="表格"></@head>
<@body menu="table">
    <div class="content-title">
        <h3>表格</h3>
        <div class="layui-btn-group">
            <button type="button" class="layui-btn layui-btn-sm">增加</button>
            <button type="button" class="layui-btn layui-btn-sm">编辑</button>
            <button type="button" class="layui-btn layui-btn-sm">删除</button>
        </div>
    </div>
    <hr>
    <table id="demo" lay-filter="test"></table>
</@body>
<@script>
    <script>
        var table = layui.table;
        $.ajax({
            url:"../findBooks",
            type:"get",
            ContentType: "application/json",
            success:function(result){
                console.log(result)
                //第一个实例
                table.render({
                    elem: '#demo',
                    height: 312,
                    data: result,
                    page: true,
                    cols: [
                        [ //表头
                            {
                                field: 'id',
                                title: 'ID',
                                width: 80,
                                sort: true,
                                fixed: 'left'
                            }, {
                            field: 'name',
                            title: '用户名',
                            width: 380
                        }, {
                            field: 'price',
                            title: '价格',
                            width: 80,
                            sort: true
                        }
                        ]
                    ]
                });


            }
        })

    </script>
</@script>